﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TechTalk.SpecFlow;
using FluentAssertions;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Support;
using OpenQA.Selenium.Support.PageObjects;
using OpenQA.Selenium.Support.UI;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Remote;

namespace DocProcessingWorkFlowScenarios
{
    class BBOS_WelcomePage
    {
        private string Environment { get; set; }

        [FindsBy(How = How.Id, Using = "SelectedEnvironment")]
        private IWebElement envDropDown;

        [FindsBy(How = How.LinkText, Using = "LOG OFF")]
        private IWebElement logOffButton;

        private static IWebDriver driver;

        public BBOS_WelcomePage()
        {
            PageFactory.InitElements(BrowserUtility.Current, this); //
        }

        public void WelcomeMessage()
        {
            Assert.IsTrue(BrowserUtility.Current.PageSource.Contains("Welcome to BBOS"), "Welcome to BBOS text not present");
        }

        public void TimeWait()
        {
            BrowserUtility.Current.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(4));
        }

        public void Dispose()
        {
            BrowserUtility.Current.Dispose();
        }

        public void Close()
        {
            BrowserUtility.Current.Close();
        }

        public void EnvirnomentDropDown()
        {
            Assert.IsTrue(envDropDown.Displayed);
            //Assert.IsTrue(BrowserUtility.Current.FindElement(By.Id("SelectedEnvironment")) != null);
        }

        public void envOptions()
        {
            Assert.IsTrue(BrowserUtility.Current.PageSource.Contains("Production"), "Production envirnoment not displayed");
            Assert.IsTrue(BrowserUtility.Current.PageSource.Contains("Test"), "Test envirnoment not displayed");
            Assert.IsTrue(BrowserUtility.Current.PageSource.Contains("DryRun"), "DryRun envirnoment not displayed");
        }

        public void SelectEnv(string environment)
        {
            this.Environment = environment;

            new SelectElement(BrowserUtility.Current.FindElement(By.Id("SelectedEnvironment"))).SelectByText(environment);
        }

        public void EnvDisplayed()
        {
            Assert.IsTrue(BrowserUtility.Current.PageSource.Contains(this.Environment), this.Environment + "envirnoment not displayed");
        }

        public void clickLogOff()
        {
            logOffButton.Click();
            //BrowserUtility.Current.FindElement(By.LinkText()).Click();
        }

    }
}
